Skip to content

Fix bugs#3

Open
damianhxy wants to merge 1 commit intohariguchi:masterfrom
damianhxy:master
Open

Fix bugs#3
damianhxy wants to merge 1 commit intohariguchi:masterfrom
damianhxy:master

Conversation

@damianhxy
Copy link
Copy Markdown

@damianhxy damianhxy commented Apr 8, 2021

Dear Yoichi,

Through testing and the use of sanitizers, I believed to have found several bugs that might be worth fixing.

ipArt.h (cmpAddr):
It should be noted that the ( len == plen ) check will never be true since the loop terminating condition is len <= plen.
In addition, with IPV6 and a plen of 128, we will have an OOB read of p1 and p2 when we check remaining bits.
I have changed the check to ( len == plen + 8 ) which correctly handles plen that are a multiple of 8.

ipArt.c (rtArtDeleteRoute): Subtract nRoutes only when default route is non-null
We are subtracting nRoutes even if the route is NULL, which can lead to nRoutes falling below 0.
In rtArtFlushRoutes, we would subsequently calloc(n, sizeof(routeEnt)) where n < 0, leading to an attempt to calloc a large amount of memory.

ipArtPathComp.c (rtArtPcDeleteRoute): Subtract nRoutes only when default route is non-null
Similar to above

ipArtPathComp.c (rtArtPcDestroy): Avoid freeing pt->pTbl which was not initialised
It seems that pt->pTbl was never initialised (unlike ipArt.c) and hence we are freeing a NULL pointer here

Best regards,
Damian

ipArt.h (cmpAddr): Fixed check to avoid OOB when plen == 128
ipArt.c (rtArtDeleteRoute): Subtract nRoutes only when default route is non-null
ipArtPathComp.c (rtArtPcDeleteRoute): Subtract nRoutes only when default route is non-null
ipArtPathComp.c (rtArtPcDestroy): Avoid freeing pt->pTbl which was not initialised
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant